package com.hd.assistant.dal.dao.ibatis;



import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.hd.assistant.dal.dao.UserDao;
import com.hd.assistant.dal.dao.exception.DAOException;
import com.hd.assistant.dal.dataobject.User;


public class IbatisUserDao extends SqlMapClientDaoSupport implements UserDao {

	public User getUserByUserIdAndType(Long userId, String userType) throws DAOException {
		try{
			User u = new User();
			u.setUserId(userId);
			u.setUserType(userType);
			return (User)this.getSqlMapClientTemplate().queryForObject("User.selectUserDOByUserid", u);
		}catch(DataAccessException e){
			throw new DAOException("IbatisUserDao.getUserByUserIdAndType", e);
		}
	}

	public void insertUser(User user)throws DAOException {
		try{
		this.getSqlMapClientTemplate().insert("User.insertUserDO", user);
	}catch(DataAccessException e){
		throw new DAOException("IbatisUserDao.insertUser", e);
	}
	}

	public void updateUser(User user)throws DAOException {
		try{
			this.getSqlMapClientTemplate().update("User.updateUserDO", user);
		}catch(DataAccessException e){
			throw new DAOException("IbatisUserDao.updateUser", e);
		}
	}
   
}
